<?php

use commands\eFlightClientFee;
use commands\EmsClientFee;
use commands\EmsImportFee;
use commands\FlightFee;
use Symfony\Component\Console\Application;

include './vendor/autoload.php';
spl_autoload_register(function ($class) {

    $file = './' . $class . '.php';
    if (is_file($file)) {
        require_once($file);
    }
});
ini_set('memory_limit', '512M');

setlocale(LC_ALL, array('zh_CN.UTF-8', 'zh_CN.gb2312', 'zh_CN.gb18030'));
//setlocale(LC_ALL, 'en_US.UTF-8');
//setlocale(LC_ALL,NULL);
setlocale(LC_ALL, 'zh_CN.UTF-8');
//error_reporting(E_ERROR);
//ini_set("display_errors", "Off");
function iconvStr($str)
{
    return iconv('gbk', 'utf-8//ignore', $str);
}

function ArrayObjecttoArray($array)
{
    $data = [];
    foreach ($array as $k => $v) {
        $row = [
            $k
        ];
        if (is_array($v)) {
            foreach ($v as $n) {
                $row[] = $n;
            }
        } else {
            $row[] = $v;
        }
        $data[] = $row;
    }
    return $data;
}

function getColIndex($code)
{
    $code = strtoupper($code);
    $n = 0;
    for ($i = 'A'; $i != 'ZZZ'; $i++) {
        if ($code == $i) break;
        $n++;
    }
    return $n;
}

function comboCsv($f1, $f2, $o)
{
    if (!is_file($f1) || !is_file($f2)) {
        echo $f1 . '||' . $f2 . '不存在';
        exit();
    }
    if (!copy($f1, $o)) {
        echo sprintf('复制%s失败', $f1);
        exit();
    }
    $fp = fopen($o, 'a+');
    $fp2 = fopen($f2, 'r');
    fgets($fp2);
    while (!feof($fp2)) {
        fwrite($fp, fgets($fp2) . "\r\n");
    }
    fclose($fp);
    fclose($fp2);
}

//var_dump(getColIndex('BT'));die();
//config


$application = new Application('EMS费用Excel计算统计工具', 'v1.0');
$application->add(new eFlightClientFee());
$application->add(new FlightFee());
$application->add(new EmsImportFee());
$application->add(new EmsClientFee());
$application->run();
exit();


